package sy.mail.thread;

import sy.mail.core.MailSenderInfo;
import sy.mail.core.SimpleMailSender;
import sy.mail.model.Mail;




/**
 * <Title></Title> 
 *
 * <Author>黄智</Author>
 *
 * <Copyright>Copyright (c) 2012</Copyright>
 *
 * <Create Date>Jul 27, 2012,9:41:48 AM</Create Date>
 *
 * <Version>1.0</Version> 
 */
public class MailThread implements Runnable {

	private Mail mail;
	private MailSenderInfo mailInfo;  //发送者
	private SimpleMailSender sms; //发送器
	public MailThread(Mail getmail){
		this.mail = getmail;
		mailInfo = new MailSenderInfo(); 
		sms = new SimpleMailSender();
	}
	
	@Override
	public void run() {
		// TODO Auto-generated method stub
         for(int i=0;i<mail.getToAddresses().size();i++){
                 //这个类主要是设置邮件
        	  mailInfo.setMailServerHost("192.168.89.109"); 
        	  mailInfo.setMailServerPort("25"); 
        	  mailInfo.setValidate(true); 
        	  mailInfo.setUserName("huangzhi"); 
        	  mailInfo.setPassword("123456");//您的邮箱密码 
        	  mailInfo.setFromAddress("hz020815@163.com"); 
        	  mailInfo.setToAddress(mail.getToAddresses().get(i).toString()); 
        	  mailInfo.setSubject("请打开邮箱"); 
        	  mailInfo.setContent("I love you !!!!"); 
                 //这个类主要来发送邮件
              //sms.sendTextMail(mailInfo);//发送文体格式 
              sms.sendHtmlMail(mailInfo);//发送html格式
        }        
	}

}
